package cn.pw.test.com.news.adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import cn.pw.test.com.news.R;
import cn.pw.test.com.news.bean.CurrencyArticleBean;
import tech.com.commoncore.manager.GlideManager;

public class CurrencyArticleAdapter extends BaseQuickAdapter<CurrencyArticleBean, BaseViewHolder> {

    public CurrencyArticleAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, final CurrencyArticleBean item) {
        helper.setText(R.id.article_item_title_tx, item.getTitle());
        helper.setText(R.id.article_item_date_tx, "来源:" + item.getFrom());
        ImageView thumbnailImg = helper.itemView.findViewById(R.id.article_item_img);
        GlideManager.loadImg(item.getImg(), thumbnailImg, R.mipmap.news_icon_placeholder);

        helper.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                ARouter.getInstance().build(NEWS_ARTICLE_DETAIL)
//                        .withString(newsArticleKey, item.getId())
//                        .greenChannel()
//                        .navigation();
//                SQLGlobal.getImp().addArticleHistory(item.title, item.img, item.id);
            }
        });
    }
}
